package com.gill.controller;

import com.gill.entity.Result;
import com.gill.entity.User;
import com.gill.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired
	private UserService userService;

	@RequestMapping(value = "/add",method = RequestMethod.POST)
	public ModelAndView addUser(@RequestParam("name") String name, @RequestParam("sex")String sex){
		User user = new User();
		user.setName(name);
		user.setSex(sex);
		Result<Object> result = userService.doSth(user);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("addUser");
		modelAndView.addObject("result",result);
		return modelAndView;
	}

	@RequestMapping(value = "/page",method = RequestMethod.GET)
	public String openPage(){
		return "addUser";
	}
}
